package lea87crzz.llega.el.tren;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.Spinner;

public class llegaeltren extends Activity {
    /** Called when the activity is first created. */
	private MyApp appState;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        final Spinner s = (Spinner) findViewById(R.id.spinner1);
        ArrayAdapter adapter = ArrayAdapter.createFromResource(
                this, R.array.estaciones, android.R.layout.simple_spinner_item);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);        
        s.setAdapter(adapter);
        s.setSelection(14);
        
        final Spinner s2 = (Spinner) findViewById(R.id.spinner2);
        ArrayAdapter adapter2 = ArrayAdapter.createFromResource(
                this, R.array.estaciones, android.R.layout.simple_spinner_item);
        adapter2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        s2.setAdapter(adapter2);
        
        final Spinner s3 = (Spinner) findViewById(R.id.spinner3);
        ArrayAdapter adapter3 = ArrayAdapter.createFromResource(
                this, R.array.horas, android.R.layout.simple_spinner_item);
        adapter3.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        s3.setAdapter(adapter3);
        s3.setSelection(8);
        
        final Spinner s4 = (Spinner) findViewById(R.id.spinner4);
        ArrayAdapter adapter4 = ArrayAdapter.createFromResource(
                this, R.array.horas, android.R.layout.simple_spinner_item);
        adapter4.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        s4.setAdapter(adapter4);
        s4.setSelection(20);
        
        final Spinner s5 = (Spinner) findViewById(R.id.spinner5);
        ArrayAdapter adapter5 = ArrayAdapter.createFromResource(
                this, R.array.dias, android.R.layout.simple_spinner_item);
        adapter5.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        s5.setAdapter(adapter5);
        
        Button b = (Button) this.findViewById(R.id.button1 );
        b.setOnClickListener(new OnClickListener( ){               

			@Override
			public void onClick(View v) {
				Intent i = new Intent( llegaeltren.this, ResultadoActivity.class);			
                i.putExtra("origen",s.getSelectedItem().toString());
                i.putExtra("destino",s2.getSelectedItem().toString());
                i.putExtra("h1",s3.getSelectedItem().toString());
                i.putExtra("h2",s4.getSelectedItem().toString());
                i.putExtra("dias",s5.getSelectedItem().toString());
                llegaeltren.this.startActivity(i);
				
			}
 
        });
    }
    
    
}